﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LibFriesland_Campina_CRM
{
    public class BizShopper
    {
        #region Thuoc tinh
        public long shopper_numid { get; set; }
        public string name { get; set; }
        public string nickname { get; set; }
        public string phone { get; set; }
        public string address { get; set; }
        public string by_na { get; set; }
        public string by_shop { get; set; }
        public DateTime datetime_create { get; set; }
        public List<BizRelatives> relatives { get; set; }
        
        //Khach hang dung nhan hang nao Product Brand
        public string fFR { get; set; }
        public string fDL { get; set; }
        #endregion

        #region Ham thiet lap
        public BizShopper() { }
        public BizShopper(long pShopper_numid, string pName, string pNickname, string pPhone, string pAddress)
        {
            shopper_numid = pShopper_numid;
            name = pName;
            nickname = pNickname;
            phone = pPhone;
            address = pAddress;
        }
        public BizShopper(long pShopper_numid, string pName, string pNickname, string pPhone, string pAddress, string pBy_na, string pBy_shop)
        {
            shopper_numid = pShopper_numid;
            name = pName;
            nickname = pNickname;
            phone = pPhone;
            address = pAddress;
            by_na = pBy_na;
            by_shop = pBy_shop;
        }
        public BizShopper(long pShopper_numid, string pName, string pNickname, string pPhone, string pAddress, string pBy_na, string pBy_shop, List<BizRelatives> pRelatives)
        {
            shopper_numid = pShopper_numid;
            name = pName;
            nickname = pNickname;
            phone = pPhone;
            address = pAddress;
            by_na = pBy_na;
            by_shop = pBy_shop;
            relatives = pRelatives;
        }
        #endregion

        #region Phuong thuc
        //Them mot shopper
        public long addShopper()
        {
            return DalShopper.addShopper(this);
        }

        //Lay danh sach Shopper
        public static List<BizShopper> getAll()
        {
            return DalShopper.getAll();
        }

        //Lay shopper id theo tieu chi loc
        public static long getShopperNumID(string pBy_na, string pName, string pNickname, string pPhone, string pAddress)
        {
            return DalShopper.getShopperNumID(pBy_na, pName, pNickname, pPhone, pAddress);
        }

        //Cap nhat thong tin shopper
        public int updateShopper()
        {
            return DalShopper.updateShopper(this);
        }

        //Cap nhat thong tin khach hang va thong tin than nhan
        public int updateShopper(BizRelatives pRelatives)
        {
            return DalShopper.updateShopper(this, pRelatives);
        }

        //Lay ngay tao record khach hang nho nhat
        public static DateTime getMinDateCreatebyShopper()
        {
            return DalShopper.getMinDateCreatebyShopper();
        }
        #endregion

        #region Dung cho Webservice
        //Lay danh sach Shopper cua NA
        public static List<BizShopper> getShopperbyNA(string pBy_na)
        {
            return DalShopper.getShopperbyNA(pBy_na);
        }

        //Lay danh sach Shopper cua NA tai mot Shop
        public static List<BizShopper> getShopperbyNA(string pBy_na, string pBy_shop)
        {
            return DalShopper.getShopperbyNA(pBy_na, pBy_shop);
        }
        #endregion

        #region Dung cho Report
        //Bao cao thong tin khach hang than thiet
        public static Dataset.DatasetShopperStatistics getShopperStatistics(DateTime pFromDate, DateTime pToDate)
        {
            return DalShopper.getShopperStatistics(pFromDate, pToDate);
        }

        #endregion
    }
}
